﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Marketplace.WebForm.Generator;

namespace Marketplace.WebForm.Account
{
    public partial class Register : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
        }

        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            
            FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);       
            
            
            TextBox TelephonTextBox=
            (TextBox) RegisterUserWizardStep.ContentTemplateContainer.FindControl("Telephone");
            TextBox AddressTextBox =
            (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Address");
            TextBox MobileTextBox =
            (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Mobile");

            var profile = Profile.CreateProfile(RegisterUser.UserName);
             profile.Telephone = TelephonTextBox.Text;         
             profile.Address = AddressTextBox.Text;
             profile.Mobile = MobileTextBox.Text;
             profile.Save();


            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (String.IsNullOrEmpty(continueUrl))
            {
                continueUrl = "~/";
            }
            Response.Redirect(continueUrl);
        }

    }
}
